@import '../../style/themes/index';
@import './mixin.less';
@tabs-prefix-cls: ~'@{kd-prefix}-tabs';
@tabPane-prefix-cls: ~'@{kd-prefix}-tab-pane';
@line-prefix-cls: ~'@{kd-prefix}-active-line';
@arrowBtn-prefix-cls: ~'@{kd-prefix}-arrow-button';
@icon-prefix-cls: ~'@{kd-prefix}icon';

.@{tabs-prefix-cls} {
  .tabs;
  &-noContainer {
    height: @tabs-height;
  }
  &-tab-wrap {
    position: relative;
    height: ~'calc(100% + 1px)';
    overflow: hidden;
    flex-grow: 1;
    font-size: 0;
  }
  &-tab-list {
    display: inline-block;
    position: absolute;
    white-space: nowrap;
    top: 0;
    left: 0;
    transition: all @tab-g-motion-duration @tab-transition-fn;
  }
  &-bottom {
    flex-direction: column-reverse;
  }
  &-left {
    flex-direction: row;
  }
  &-right {
    flex-direction: row-reverse;
  }

  &-left-arrows {
    box-shadow: 2px 0 2px rgba(0, 0, 0, 0.08);
    height: 100%;
    display: flex;
    align-items: center;
    &-line {
      background-color: #fff;
    }
    &-noshadow {
      box-shadow: unset;
    }
  }
  &-right-arrows {
    box-shadow: -2px 0 2px rgba(0, 0, 0, 0.08);
    height: 100%;
    display: flex;
    align-items: center;
    &-line {
      background-color: #fff;
      .@{tabs-prefix-cls}-more-btn {
        width: 24px;
      }
    }
    &-grid {
      background-color: #fff;
      box-shadow: unset;
      border: 1px solid @tabs-border-color;
      .@{tabs-prefix-cls}-more-btn {
        line-height: 22px;
      }
    }
    &-noshadow {
      box-shadow: unset;
    }
    .@{icon-prefix-cls} {
      font-size: 14px;
    }
  }
  &-left-operations {
    position: relative;
    margin-right: 2px;
    &-item {
      padding: 0 12px;
      cursor: pointer;
    }
  }
  &-right-operations {
    position: relative;
    padding-right: 18px;
    &-item {
      padding-left: 12px;
      cursor: pointer;
    }
  }

  &-more-btn {
    display: inline-block;
    box-sizing: border-box;
    width: 48px;
    text-align: center;
    cursor: pointer;
    &:hover {
      color: @tabPane-font-color-hover;
    }
    &-disabled {
      color: @tabPane-font-color-disabled;
      cursor: not-allowed;
      &:hover {
        color: @tabPane-font-color-disabled;
      }
    }
  }
}

.@{tabs-prefix-cls}-navs {
  .tabNavs;
  &-line {
    &.@{tabs-prefix-cls}-navs-middle {
      height: @tab-pane-type-line-height-middle;
    }
    &.@{tabs-prefix-cls}-navs-small {
      height: @tab-pane-type-line-height-small !important;
    }
    .@{tabPane-prefix-cls}-middle {
      line-height: @tab-pane-type-line-height-middle;
      height: @tab-pane-type-line-height-middle;
    }
    .@{tabPane-prefix-cls}-small {
      line-height: @tab-pane-type-line-height-small;
      height: @tab-pane-type-line-height-small;
    }
    &.@{tabs-prefix-cls}-navs-bottom {
      border-top: 1px solid @tabs-border-color;
      border-bottom: unset;
      .@{tabs-prefix-cls}-tab-wrap {
        margin-top: -1px;
      }
      .@{tabs-prefix-cls}-tab-list {
        top: -1px;
      }
      .@{line-prefix-cls} {
        top: 1px;
        bottom: unset;
      }
    }
  }
  &-card {
    border-top: 1px solid @tabs-border-color;
    background-color: @tabs-card-bg;
    .@{tabs-prefix-cls}-tab-wrap {
      top: -1px;
      height: ~'calc(100% + 2px)';
    }
    &.@{tabs-prefix-cls}-navs-left,
    &.@{tabs-prefix-cls}-navs-right {
      min-width: 120px;
      height: 100%;
      font-size: 0;
      border-top: 1px solid transparent;
      &::before,
      &::after {
        position: absolute;
        content: '';
        display: inline-block;
        width: 1px;
        height: 100%;
        background-color: @tabs-border-color;
      }
      &::before {
        left: 0;
      }
      &::after {
        right: 0;
      }
      .@{tabs-prefix-cls}-tab-wrap {
        box-sizing: border-box;
        min-width: 120px;
        width: 100%;
        z-index: 2;
      }
      .@{tabs-prefix-cls}-tab-list {
        display: flex;
        flex-direction: column;
        white-space: normal;
        width: 100%;
        height: 100%;
        min-width: 120px;
        max-height: 100%;
        overflow: auto;
      }
    }
  }
  &-grid {
    height: 24px;
    border-bottom: unset;
  }
  &-dynamic {
    background-color: @tabs-card-bg;
    border-bottom: unset;
    height: @tab-pane-type-dynamic-height;
    .@{tabs-prefix-cls}-tab-wrap {
      height: @tab-pane-type-dynamic-height;
    }
    .@{tabs-prefix-cls}-more-btn {
      line-height: @tab-pane-type-dynamic-height;
    }
  }
  &-small:not(.@{tabs-prefix-cls}-navs-left):not(.@{tabs-prefix-cls}-navs-right) {
    height: 36px;
    &.@{tabs-prefix-cls}-card-more {
      padding-right: 36px;
    }
  }
}

.@{tabPane-prefix-cls} {
  .tabPane;
  &-text {
    display: inline-block;
    transition: color @tab-g-motion-duration;
    &-active,
    &:hover {
      color: @tabPane-font-color-active;
    }
    &-disabled {
      &:hover {
        color: @tabPane-font-color-disabled;
      }
    }
  }
  &-disabled {
    color: @tabPane-font-color-disabled;
    cursor: not-allowed;
    &:hover {
      color: @tabPane-font-color-disabled;
    }
  }
  &-type-line {
    padding: 0 @tab-pane-line-paddinng-horizontal;
  }
  &-type-card {
    margin-right: 0;
    padding: 0 @tab-pane-card-paddinng-horizontal;
    border: 1px solid transparent;
    &.@{tabPane-prefix-cls}-box-active {
      background-color: #fff;
      border: 1px solid @tabs-border-color;
      border-top: 2px solid;
      border-color: @tab-line-color-active @tabs-border-color transparent @tabs-border-color;
      transition: background-color 0.2s @tab-transition-fn;
      &:first-of-type {
        border-left-color: transparent;
      }
    }
    &.@{tabPane-prefix-cls}-left {
      border-left: 2px solid transparent;
      &.@{tabPane-prefix-cls}-box-active {
        border-left: 2px solid;
        border-color: @tabs-border-color transparent transparent @tab-line-color-active;
      }
    }
    &.@{tabPane-prefix-cls}-right {
      border-right: 1px solid transparent;
      &.@{tabPane-prefix-cls}-box-active {
        border-right: 2px solid @tab-line-color-active;
        border-left: 1px solid transparent;
      }
    }
    &.@{tabPane-prefix-cls}-left,
    &.@{tabPane-prefix-cls}-right {
      width: 100%;
      border-top: 1px solid @tabs-border-color;
      &:last-of-type {
        border-bottom: 1px solid @tabs-border-color;
      }
    }
    &.@{tabPane-prefix-cls}-bottom {
      border-top: 1px solid transparent;
      border-bottom: 2px solid transparent;
      &.@{tabPane-prefix-cls}-box-active {
        border-bottom: 2px solid;
        border-color: transparent @tabs-border-color @tab-line-color-active @tabs-border-color;
        &:first-of-type {
          border-left-color: transparent;
        }
      }
    }
    &.@{tabPane-prefix-cls}-top {
      border-top: 2px solid transparent;
      &.@{tabPane-prefix-cls}-box-active {
        border-top: 2px solid;
        border-color: @tab-line-color-active @tabs-border-color transparent @tabs-border-color;
        &:first-of-type {
          border-left-color: transparent;
        }
      }
    }
  }
  &-type-dynamic {
    height: @tab-pane-type-dynamic-height;
    line-height: @tab-pane-type-dynamic-height;
    margin: 0 0 0 4px;
    display: inline-flex;
    align-items: center;
    &:not(.@{tabPane-prefix-cls}-disabled):hover {
      .@{tabPane-prefix-cls}-operations {
        span:first-child {
          opacity: 1;
          cursor: pointer;
        }
      }
    }
    .@{tabPane-prefix-cls}-operations .@{icon-prefix-cls} {
      font-size: 16px;
    }
  }
  &-type-grid {
    height: 24px;
    line-height: 22px;
    padding: 0 @tab-pane-grid-paddinng-horizontal;
    border: 1px solid @tabs-border-color;
    margin-right: -1px;
    &:first-of-type {
      border-radius: 2px 0 0 2px;
    }
    &:last-of-type {
      border-radius: 0 2px 2px 0;
    }
    &.@{tabPane-prefix-cls}-box-active {
      position: relative;
      z-index: 2;
      background-color: @tab-line-color-active;
      border: 1px solid @tab-line-color-active;
      transition: background-color 0.2s @tab-transition-fn;
      .@{tabPane-prefix-cls}-text-active {
        color: #fff;
      }
    }
    &.@{tabPane-prefix-cls}-disabled {
      background-color: @tab-disabled-bg;
    }
    &:hover {
      color: @tabPane-font-color-active;
    }
  }
  &-operations {
    position: relative;
    display: inline-block;
    line-height: 1;
    padding: 0 4px;
    span:first-child {
      display: inline-block;
      vertical-align: top;
      font-size: 0;
      opacity: 0;
    }
  }
  &-small {
    height: 36px;
    line-height: 36px;
  }
}

.@{line-prefix-cls} {
  position: absolute;
  display: inline-block;
  box-sizing: border-box;
  width: auto;
  left: 0;
  bottom: 0;
  height: 2px;
  background-color: @tab-line-color-active;
  transition: all @tab-g-motion-duration @tab-transition-fn;
}

.@{arrowBtn-prefix-cls} {
  display: inline-block;
  box-sizing: border-box;
  width: 48px;
  text-align: center;
  cursor: pointer;
  &:hover {
    color: @tabPane-font-color-hover;
  }
  &-line {
    width: 24px;
  }
  &-dynamic {
    width: 24px;
    line-height: @tab-pane-type-dynamic-height;
  }
  &-disabled {
    color: @tabPane-font-color-disabled;
    cursor: not-allowed;
    &:hover {
      color: @tabPane-font-color-disabled;
    }
  }
  .@{icon-prefix-cls} {
    font-size: 14px;
  }
}
